import java.util.Arrays;

public class MyStack {
  private int[] elem  ;
  private int usedSize ;
  private static final int DEFAULT_CAPACITY = 5 ;

    public MyStack() {
        this.elem = new int[DEFAULT_CAPACITY];
    }
    public void push(int data){
        if(this.usedSize < this.elem.length){
            this.elem[this.usedSize] = data ;
            usedSize++ ;
        }else{
            this.elem = Arrays.copyOf(this.elem ,this.elem.length*2) ;
            this.elem[this.usedSize] = data ;
            this.usedSize++ ;
        }
    }
    public int pop(){
        if(this.usedSize<1){
            throw new NullPointerException();
        }
        return this.elem[--this.usedSize] ;
    }
}
class Test{
    public static void main(String[] args) {
        MyStack myStack  = new MyStack();
        myStack.push(1);
        myStack.push(2);
        myStack.push(3);
        myStack.push(4);
        myStack.push(5);
        myStack.push(6);
      


    }
}